from collections import Counter
import pymongo
import pandas as pd

shipMongoDB = pymongo.MongoClient("mongodb://admin:zdiai%40123@172.16.1.31:27017/")
shipData = shipMongoDB["Repo_history"]
shipTable = shipData['zhonghaiyoufu_5min']
selectedData = pd.DataFrame(
    shipTable.find({"timestamp": {"$gte": 1648788302, "$lte": 1648813002}}, {'AQ020109002': 1}))
workCon = round(selectedData['AQ020109002']/50)
workCon = workCon * 50


workCon_Count = Counter(workCon)
workCon_Count = sorted(workCon_Count.items(), key=lambda d: d[1], reverse=True)
print(workCon_Count)
workDuration = {}
for x in workCon_Count:
   workDuration[x[0]] = x[1] * 5

print(workDuration)